<?php

use yii\db\Migration;

/**
 * Class m211220_070340_add_user_rate_limit
 */
class m211220_070340_add_user_rate_limit extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->addColumn('{{%user}}', 'allowance', $this->integer()->defaultValue(0)->notNull()->comment("在allowance_updated_at设定的时间达到之前还剩下多少次可以调用"));
        $this->addColumn('{{%user}}', 'allowance_updated_at', $this->integer(11)->defaultValue(0)->notNull()->comment("本周期结束的时间戳"));
        return true;
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropColumn('{{%user}}', "allowance");
        $this->dropColumn('{{%user}}', "allowance_updated_at");
        return true;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m211220_070340_add_user_rate_limit cannot be reverted.\n";

        return false;
    }
    */
}
